package edu.gdin.ecommerce.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.gdin.ecommerce.util.DateUtil;
import edu.gdin.ecommerce.util.DicConverter;

/**
 * Inventory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_inventory", catalog = "ecommerce")
public class Inventory implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -357843663836616731L;
	private String inventoryNo;
	private String password;
	private String batchNo;
	private Integer status;
	private String applicant;
	private Integer materialType;
//	private Integer cardIssuerId;
	private BigDecimal faceValue;
	private String tracks1;
	private String tracks2;
	private Date createTime;
	private String inventoryDesc;
	private CardIssuer cardIssuer;

	// Constructors

	/** default constructor */
	public Inventory() {
	}

	/** full constructor */
	public Inventory(String inventoryNo, String password, String batchNo,
			Integer status, String applicant, Integer materialType,
			BigDecimal faceValue, String tracks1, String tracks2, Date createTime,
			String inventoryDesc, CardIssuer cardIssuer) {
		super();
		this.inventoryNo = inventoryNo;
		this.password = password;
		this.batchNo = batchNo;
		this.status = status;
		this.applicant = applicant;
		this.materialType = materialType;
		this.faceValue = faceValue;
		this.tracks1 = tracks1;
		this.tracks2 = tracks2;
		this.createTime = createTime;
		this.inventoryDesc = inventoryDesc;
		this.cardIssuer = cardIssuer;
	}

	
	// Property accessors
	@Id
	@Column(name = "INVENTORY_NO", unique = true, nullable = false, length = 20)
	public String getInventoryNo() {
		return this.inventoryNo;
	}

	public void setInventoryNo(String inventoryNo) {
		this.inventoryNo = inventoryNo;
	}

	@Column(name = "PASSWORD", nullable = false, length = 10)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@Column(name = "BATCH_NO", nullable = false, length = 20)
	public String getBatchNo() {
		return this.batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	@Column(name = "STATUS", nullable = false)
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "APPLICANT", nullable = false, length = 20)
	public String getApplicant() {
		return this.applicant;
	}

	public void setApplicant(String applicant) {
		this.applicant = applicant;
	}

	@Column(name = "MATERIAL_TYPE", nullable = false)
	public Integer getMaterialType() {
		return this.materialType;
	}

	public void setMaterialType(Integer materialType) {
		this.materialType = materialType;
	}

	@Column(name = "FACE_VALUE", precision = 12)
	public BigDecimal getFaceValue() {
		return this.faceValue;
	}

	public void setFaceValue(BigDecimal faceValue) {
		this.faceValue = faceValue;
	}

	@Column(name = "TRACKS1", nullable = false, length = 20)
	public String getTracks1() {
		return this.tracks1;
	}

	public void setTracks1(String tracks1) {
		this.tracks1 = tracks1;
	}

	@Column(name = "TRACKS2", nullable = false, length = 20)
	public String getTracks2() {
		return this.tracks2;
	}

	public void setTracks2(String tracks2) {
		this.tracks2 = tracks2;
	}

	@Column(name = "CREATE_TIME", nullable = false, length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "INVENTORY_DESC", length = 200)
	public String getInventoryDesc() {
		return this.inventoryDesc;
	}

	public void setInventoryDesc(String inventoryDesc) {
		this.inventoryDesc = inventoryDesc;
	}


	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CARD_ISSUER_ID", nullable = false)
	public CardIssuer getCardIssuer() {
		return cardIssuer;
	}

	public void setCardIssuer(CardIssuer cardIssuer) {
		this.cardIssuer = cardIssuer;
	}
	
	
	// -- property Converter --
	
	public String statusToString() {
		return DicConverter.dicMapConvert("DIC_CARD_BATCH_STATUS", this.getStatus());
	}
	
	
	public String materialTypeToString() {
		return DicConverter.dicMapConvert("DIC_CARD_MATERIAL_TYPE", this.getMaterialType());
	}
	
	
	public String createTimeToString() {
		return DateUtil.dateFormat(this.createTime);
	}
	

}